package com.xyy.saas.payment.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * @author wangzeqi
 */
@Getter
@AllArgsConstructor
public enum SeparateOrderAsyncTradeStatus {

    /**
     * 处理中
     */
    PROCESSING("0"),

    /**
     * 处理成功
     */
    FINISHED("1"),

    /**
     * 处理失败
     */
    FAILED("2"),
    ;

    private final String status;

    public static SeparateOrderAsyncTradeStatus fromStatus(String status) {
        return Arrays.stream(SeparateOrderAsyncTradeStatus.values())
                .filter(s -> Objects.equals(s.getStatus(), status))
                .findFirst()
                .orElse(null);
    }

    public static Set<String> finalStatus() {
        HashSet<String> set = new HashSet<>();
        set.add(FINISHED.getStatus());
        set.add(FAILED.getStatus());
        return set;
    }

}
